ask "Which" && resType && "do you want to check for?"
put it into resName
get IsResource(resType, resName)
if it is true then
answer item 1 of resInfo && item 3 of resInfo & "," && item 2 of resInfo & "," && item 4 of resInfo && "bytes." with "OK"
else answer resType && resName && "not found." with "OK"
end mouseUp
-- part 2 (field)
-- low flags: 81
-- high flags: 2007
-- rect: left=12 top=26 right=298 bottom=491
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 22
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Source
-- part 3 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=299 top=300 right=322 bottom=438
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Show Pascal Source
----- HyperTalk script -----
on mouseUp
set the visible of card field 1 to not the visible of card field 1
if the visible of card field 1 is true then
set the name of me to "Hide Pascal Source"
else set the name of me to "Show Pascal Source"
end mouseUp
-- part contents for background part 16
----- text -----
ISRESOURCE XFCN version 1.0.2
Kevin Calhoun
IsResource checks for the availability of a resource by its resource type and name, by its resource type and ID, or by its resource type, name, and ID. You can check for the presence of a resource in any currently open resource file or in just the most recently opened resource file.
If IsResource returns TRUE, additional information about the resource will be available in the global variable "resInfo." (This requires HyperCard 1.2 or later.) Item 1 of resInfo will be the resource type, item 2 the resource name, item 3 the resource ID, item 4 the size of the resource in bytes, and item 5 the name of the resource file in which the resource was found.
INVOKING ISRESOURCE
get IsResource("resType",<"resName">,<resID>,<mostRecentOnly>)
result: true or false
If the fourth parameter, which is optional, is TRUE, IsResource checks only the most recently opened resource file. Note that the most recently opened resource file is not necessarily that of the current stack (the current stack might not have a resource fork). If you want to be certain that an existing resource is contained in a particular stack, use the following function:
function ResInStack resType,resName,resID,stackName
global resInfo
lock screen
push card
go to stack stackName
put the long name of this stack into stackPathname
delete word 1 of stackPathname
delete char 1 of stackPathname
delete last char of stackPathName
put IsResource(resType,resName,resID,TRUE) into resExists
pop card
unlock screen
if resExists is FALSE then return FALSE
else return (item 5 of resInfo is stackPathname)
end ResInStack
EXAMPLES
IsResource("XCMD", "PrintField") would return true if an XCMD named PrintField were available in any one of the currently open resource files. IsResource("XCMD", "PrintField", 9140) would return true if an XCMD named PrintField and numbered 9140 were available in any currently open resource file. IsResource("XCMD",empty, 9140) would return true if any XCMD numbered 9140 were currently available.
REVISION HISTORY
15 March 1989 1.0
30 April 1989 1.0.1 -- Item 5 of global resInfo is now full pathname of file containing resource. Also, IsResource no longer leaves an orphaned handle in heap.
11 June 1989 1.0.2 -- Fixed problem of not getting full pathname of system file when resource lives there. Inside Macintosh lies. Volume 1, page 116: "When calling...HomeResFile..., be aware that for the system resource file the actual reference number is returned." Not true. Zero is returned. Also, fixed problem of not returning the resource type correctly when a resource type of more than 4 characters is supplied. (IsResource ignores the extra characters.)
-- part contents for card part 2
----- text -----
UNIT IsResourceUnit;
{ IsResource XFCN © 1989 by the Trustees of Dartmouth College }